package gamemap

import "encoding/binary"

func MapToBinary(m *Bmap) []byte { 
	buffer:=make([]byte,m.Size*m.Size*2+4)
	//将地图大小写入buffer
	binary.BigEndian.PutUint32(buffer,uint32(m.Size))

	for i:=0;i<m.Size;i++{
		for j:=0;j<m.Size;j++{
			binary.BigEndian.PutUint16(buffer[4+i*m.Size*2+j*2:],uint16(m.Blocks[i][j]))
		}
	}
	return buffer
}

func Clone(m *Bmap) *Bmap{
	nmap:=new(Bmap)
	nmap.path=m.path
	nmap.Name=m.Name
	nmap.Size=m.Size
	copy(nmap.Blocks,m.Blocks)
	return nmap
}